<!--考核项详情-->
<template>
  <div id="cornerComment" v-if="dialogVisible">
    <div class="cornerComment-in" ref="dialogBox">
      <div class="cornerComment-in-title">
        <span>编辑幼儿接送家长信息</span>
        <span class="el-icon-circle-close close-Btn-line" @click="closePOpup"></span>
      </div>
      <div class="commentBody">
        <div class="setinfobox">
          <div class="setinfobox-right-body">
            <div class="setinfobox-right-body-top-from" v-if="pickInfo">
              <el-form ref="form" label-width="110px">
                <el-form-item label="接送人称呼">
                  <el-input v-model="pickInfo.relation" size="small" placeholder="请输入接送人称呼"></el-input>
                </el-form-item>
                <el-form-item label="接送人身份证">
                  <el-input v-model="pickInfo.identity_card" size="small" placeholder="请输入接送人身份证"></el-input>
                </el-form-item>
                <el-form-item label="接送人近照">
                  <div>
                    <el-upload
                        class="avatar-uploader"
                        :action="$uploadZipImg"
                        accept="image/jpg,image/jpeg,image/png"
                        :show-file-list="false"
                        :on-success="handleAvatarSuccess"
                        :before-upload="beforeAvatarUpload">
                      <img v-if="pickInfo.pic" :src="`${pickInfo.pic}`" class="avatar"
                           @click="uploadImg()">
                      <i v-else class="el-icon-plus avatar-uploader-icon" @click="uploadImg()"></i>
                    </el-upload>
                  </div>
                </el-form-item>
              </el-form>
            </div>
          </div>
        </div>
      </div>
      <div class="cornerComment-in-footer">
        <el-button @click="closePOpup" size="mini">返回</el-button>
        <el-button @click="activeFn" size="mini" type="primary">确认并保存</el-button>
      </div>
    </div>
  </div>
</template>

<script>
import {pick_edit} from '@/api/admin/ClassDynamics'

export default {
  props: ['visible', 'detailOption'],
  components: {},
  data() {
    return {
      dialogVisible: false,
      pickInfo: null
    }
  },
  watch: {
    visible() {
      this.dialogVisible = this.visible
      if (this.visible) {
        console.log('detailOption:', this.detailOption)
        this.pickInfo = this.detailOption
      } else {
        this.pickInfo = null
      }
    }
  },
  created() {
  },
  methods: {
    activeFn() {
      let data_ = {
        id: this.pickInfo.id, //
        mobile_phone: this.pickInfo.mobile_phone, //  电话
        identity_card: this.pickInfo.identity_card, //  身份证
        relation: this.pickInfo.relation, // 关系
        pic: this.pickInfo.pic, // 图片
      }
      // 请求就送信息 获取接送信息
      pick_edit(data_).then(res => {
        console.log('请求就送信息', res)
        if (!res.code) {
          this.$message.success(res.msg)
          this.$emit('InitFn')
          this.closePOpup()
        }
      })
    },
    uploadImg(index) {
      this.uploadIndex = index
    },
    getJson(option) {
      return JSON.parse(JSON.stringify(option))
    },
    // 关闭弹窗
    closePOpup() {
      this.$emit('update:visible', false)
    },
    handleAvatarSuccess(res, file) {
      console.log('indexlist: ', res, file)
      this.pickInfo.pic = res.pic
    },
    beforeAvatarUpload(file) {
      console.log(file)
    }
  },
  mounted() {
  }
}
</script>
<style scoped>
#cornerComment {
  height: 100vh;
  width: 100%;
  position: fixed;
  top: 0;
  left: 0;
  background: rgba(0, 0, 0, .5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9;
}

.cornerComment-in {
  width: 400px;
  height: 400px;
  background: #fff;
  display: flex;
  flex-direction: column;
  border-radius: 5px;
}

.cornerComment-in-title {
  height: 50px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid #ddd;
  font-size: 24px;
}

.cornerComment-in-title span {
  padding: 0 10px;
}

.cornerComment-in-title span:first-child {
  flex: 1;
  font-size: 16px;
}

.cornerComment-in-footer {
  height: 50px;
  border-top: 1px solid #ddd;
  display: flex;
  align-items: center;
  padding: 0 10px;
  justify-content: center;
}

.commentBody {
  padding: 10px;
  flex: 1;
  overflow-y: auto;
}

.close-Btn-line {
  cursor: pointer;
}


.apply-code-img img {
  width: 160px;
  height: 160px;
  margin: 60px auto 10px;
  display: block;
}

.getcode {
  width: 100%;
  text-align: center;
}

.setinfobox {
  display: flex;
  height: 100%;
}

.setinfobox-left {
  flex: 1;
  margin-right: 10px;
  border: 1px solid #ddd;
  display: flex;
  flex-direction: column;
}

.setinfobox-left-c {
  height: 40px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  border-bottom: 1px solid #ddd;
}

.setinfobox-left-list {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.setinfobox-right {
  width: 300px;
  border: 1px solid #ddd;
  display: flex;
  flex-direction: column;
}

.setinfobox-right-title {
  height: 40px;
  border-bottom: 1px solid #ddd;
  display: flex;
  align-items: center;
  justify-content: center;
}

.setinfobox-right-body-footer {
  height: 40px;
  border-top: 1px solid #ddd;
  display: flex;
  align-items: center;
  justify-content: center;
}

.setinfobox-right-body {
  flex: 1;
  overflow-y: auto;
}

.setinfobox-right-body-top-from {
  margin: 5px;
  background: #f9f9f9;
  border-radius: 5px;
  padding: 5px;
  border: 1px solid #eee;
}

.setinfobox-left-list-title {
  height: 30px;
}

.setinfobox-left-list-title span {
  flex: 1;
  text-align: center;
  line-height: 30px;
}

.setinfobox-left-list-inline {
  display: flex;
  height: 30px;
  border-bottom: 1px solid #ddd;
  background: #f4f4f4;
}

.setinfobox-left-list-body {
  flex: 1;
  overflow-y: auto;
}

.setinfobox-left-list-body p {
  text-align: center;
  padding: 40px;
  color: #999;
}

.setinfobox-right-body p {
  text-align: center;
  padding: 40px;
  color: #999;
}

.setinfobox-list {
  display: flex;
  height: 30px;
  cursor: pointer;
  border-bottom: 1px dashed #ddd;
}

.setinfobox-list .iconfont {
  color: #1dc053;
  font-size: 24px;
}

.setinfobox-list:hover {
  background: #e6f5ff;
}

.setinfobox-list.active {
  background: #e6f5ff;
}

.setinfobox-list span {
  display: block;
  flex: 1;
  text-align: center;
  line-height: 30px;
}
</style>

